﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Generator.TemplateBlockCodeGenerator
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.Web.Razor.Parser.SyntaxTree;

namespace System.Web.Razor.Generator
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents the template block code generator of the razor.</summary>
  public class TemplateBlockCodeGenerator : BlockCodeGenerator
  {
    private const string TemplateWriterName = "__razor_template_writer";
    private const string ItemParameterName = "item";
    private string _oldTargetWriter;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates code to start the block for the template block code generator.</summary>
    /// <param name="target">The target block.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
    {
      string fragment = context.BuildCodeString((Action<CodeWriter>) (cw =>
      {
        cw.WriteStartLambdaExpression("item");
        cw.WriteStartConstructor(context.Host.GeneratedClassContext.TemplateTypeName);
        cw.WriteStartLambdaDelegate("__razor_template_writer");
      }));
      context.MarkEndOfGeneratedCode();
      context.BufferStatementFragment(fragment);
      context.FlushBufferedStatement();
      this._oldTargetWriter = context.TargetWriterName;
      context.TargetWriterName = "__razor_template_writer";
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates code to end the block of the template block code generator.</summary>
    /// <param name="target">The target block.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
    {
      string fragment = context.BuildCodeString((Action<CodeWriter>) (cw =>
      {
        cw.WriteEndLambdaDelegate();
        cw.WriteEndConstructor();
        cw.WriteEndLambdaExpression();
      }));
      context.BufferStatementFragment(fragment);
      context.TargetWriterName = this._oldTargetWriter;
    }
  }
}
